﻿using IM.Easy.Core.ServiceLifetime;
using IM.Easy.Entity.Scheduled;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IM.Easy.ScheduledServices.IServices
{
    public interface ISchedulerService : ISingleton
    {
        /// <summary>
        /// 调度器
        /// </summary>
        IScheduler Scheduler { get; }

        /// <summary>
        /// 新增一个任务计划
        /// </summary>
        Task NewScheduler(ScheduledJob job);

        /// <summary>
        /// 移除一个任务计划
        /// </summary>
        /// <returns></returns>
        Task<bool> RemoveScheduler(string schedulerId);

        /// <summary>
        /// 批量移除任务计划
        /// </summary>
        /// <param name="schedulerIds"></param>
        /// <returns></returns>
        Task<bool> RemoveSchedulers(params string[] schedulerIds);

        /// <summary>
        /// 启动一个任务
        /// </summary>
        /// <returns></returns>
        Task<DateTimeOffset> StartScheduler(JobTrigger trigger);

        /// <summary>
        /// 暂停一个任务
        /// </summary>
        /// <param name="schedulerId"></param>
        /// <returns></returns>
        Task PauseScheduler(string triggerId);

        /// <summary>
        /// 恢复一个任务
        /// </summary>
        /// <param name="schedulerId"></param>
        /// <returns></returns>
        Task ResumeScheduler(string triggerId);

        /// <summary>
        /// 执行一次任务
        /// </summary>
        /// <returns></returns>
        Task TriggerOnce(string schedulerId);

    }
}
